﻿Imports System.Runtime.CompilerServices

Module modMain
    Public Function GetMimeType(ByVal httpRequest As String) As String
        Try
            If (httpRequest.EndsWith("html")) Then
                Return "text/html"
            ElseIf (httpRequest.EndsWith("htm")) Then
                Return "text/html"
            ElseIf (httpRequest.EndsWith("js")) Then
                Return "application/javascript"
            ElseIf (httpRequest.EndsWith("css")) Then
                Return "text/css"
            ElseIf (httpRequest.EndsWith("txt")) Then
                Return "text/plain"
            ElseIf (httpRequest.EndsWith("gif")) Then
                Return "image/gif"
            ElseIf (httpRequest.EndsWith("png")) Then
                Return "image/png"
            ElseIf (httpRequest.EndsWith("jpg")) Then
                Return "image/jpeg"
            ElseIf (httpRequest.EndsWith("jpeg")) Then
                Return "image/jpeg"
            ElseIf (httpRequest.EndsWith("pdf")) Then
                Return "application/pdf"
            ElseIf (httpRequest.EndsWith("doc")) Then
                Return "application/msword"
            ElseIf (httpRequest.EndsWith("xls")) Then
                Return "application/vnd.ms-excel"
            ElseIf (httpRequest.EndsWith("ppt")) Then
                Return "application/vnd.ms-powerpoint"
            ElseIf (httpRequest.EndsWith("ico")) Then
                Return "image/icon"
            ElseIf (httpRequest.EndsWith("mp3")) Then
                Return "audio/mp3"
            Else
                Return "text/plain"
            End If

        Catch ex As Exception
            Return "text/plain"
        End Try
    End Function

    <Extension()> _
    Public Function ToHttpDateFormat(ByVal D As Date) As String
        'Thu, 30 Dec 2010 16:33:13 GMT
        Return D.ToString("ddd, dd MMM yyyy hh:mm:ss G\MT")
    End Function
End Module
